package com.cn.ant.modules.wechat.entity;

import java.util.List;

public class MenuEntity {
    private String id;

    private String menukey;

    private String msgtype;

    private String name;

    private String orders;

    private String templateid;

    private String templatename;

    private String type;

    private String url;

    private String fatherid;

    private String accountid;

    private MenuEntity parent;//上一级

    private List<MenuEntity> childList;//下一级

    public MenuEntity() {
        super();
    }

    public MenuEntity(String id, String menukey, String msgtype, String name, String orders, String type, String url, String fatherid, String accountid) {
        this.id = id;
        this.menukey = menukey;
        this.msgtype = msgtype;
        this.name = name;
        this.orders = orders;
        this.type = type;
        this.url = url;
        this.fatherid = fatherid;
        this.accountid = accountid;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id == null ? null : id.trim();
    }

    public String getMenukey() {
        return menukey;
    }

    public void setMenukey(String menukey) {
        this.menukey = menukey == null ? null : menukey.trim();
    }

    public String getMsgtype() {
        return msgtype;
    }

    public void setMsgtype(String msgtype) {
        this.msgtype = msgtype == null ? null : msgtype.trim();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    public String getOrders() {
        return orders;
    }

    public void setOrders(String orders) {
        this.orders = orders == null ? null : orders.trim();
    }

    public String getTemplateid() {
        return templateid;
    }

    public void setTemplateid(String templateid) {
        this.templateid = templateid == null ? null : templateid.trim();
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type == null ? null : type.trim();
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url == null ? null : url.trim();
    }

    public String getFatherid() {
        return fatherid;
    }

    public void setFatherid(String fatherid) {
        this.fatherid = fatherid == null ? null : fatherid.trim();
    }

    public String getAccountid() {
        return accountid;
    }

    public void setAccountid(String accountid) {
        this.accountid = accountid == null ? null : accountid.trim();
    }

    public String getTemplatename() {
        return templatename;
    }

    public void setTemplatename(String templatename) {
        this.templatename = templatename;
    }

    public MenuEntity getParent() {
        return parent;
    }

    public void setParent(MenuEntity parent) {
        this.parent = parent;
    }

    public List<MenuEntity> getChildList() {
        return childList;
    }

    public void setChildList(List<MenuEntity> childList) {
        this.childList = childList;
    }

    public static void sortList(List<MenuEntity> list, List<MenuEntity> sourcelist, String parentId) {
        for (int i = 0; i < sourcelist.size(); i++) {
            MenuEntity e = sourcelist.get(i);
            if (e.getFatherid() != null && e.getFatherid().equals(parentId)) {
                list.add(e);
                // 判断是否还有子节点, 有则继续获取子节点
                for (int j = 0; j < sourcelist.size(); j++) {
                    MenuEntity child = sourcelist.get(j);
                    if (child.getFatherid() != null && child.getFatherid().equals(e.getId())) {
                        sortList(list, sourcelist, e.getId());
                        break;
                    }
                }
            }
        }
    }
}